
//设置cookie，time表示分钟
export function setCookie(cname,cvalue,time){
	var d = new Date();
	d.setTime(d.getTime() + (time*60*1000));
	var expires = "expires="+d.toGMTString();
	document.cookie = cname + "=" + cvalue + "; " + expires;
}

//保存cookie不带事件，浏览器关闭自动删除
export function setCookieNoTime(cname,cvalue){
  document.cookie = cname + "=" + cvalue
}

//获取cookie
export function getCookie(cname){
	var name = cname + "=";
	var ca = document.cookie.split(';');
	for(var i=0; i<ca.length; i++) {
		var c = ca[i].trim();
		if (c.indexOf(name)==0) { return c.substring(name.length,c.length); }
	}
	return "";
}

//删除cookie
export function removeCookie(cname){
  document.cookie = cname + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT";
  return true;
}